package net.mysoft.framework.util;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class UrlUtil {
	public static String addParams(String url,Map params) {
		if(url!=null){
			String paramStr = "";
			Set set = params.keySet();
			Iterator ite = set.iterator();
			int i = 0;
			while(ite.hasNext()){
				String key = ite.next()+"";
				String value = params.get(key)+"";
				if(key!=null&&!"".equals(key)&&value!=null&&!"".equals(value)){
					if(i>0)paramStr+="&";
					paramStr +=key+"="+value;
					i++;
				}
			}
			
			if(url.indexOf("?")>0){
				return url+"&"+paramStr;
			}else{
				return url+"?"+paramStr;
			}			
		}
		return null;
	}
}
